//
//  HomePageTitleView.m
//  jzyStudents
//
//  Created by 任辰东 on 2022/9/22.
//

#import "HomePageTitleView.h"

@interface HomePageTitleView ()

@property (nonatomic, strong) UIView *imgView;
@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, copy) NSString *title;
@end

@implementation HomePageTitleView

-(instancetype)initWithTitle:(NSString *)title
{
    self = [super init];
    if (self) {
        _title = title;
        [self setupViews];
        [self setupLayout];
    }
    return self;
}

-(void)setupViews
{
    self.titleLabel.text = self.title;
    self.backgroundColor = UIColorFromHex(kColorWhite);
    [self addSubview:self.imgView];
    [self addSubview:self.titleLabel];
}

-(void)setupLayout
{
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self).offset(15);
        make.centerY.equalTo(self).offset(0);
        make.height.mas_equalTo(14);
        make.width.mas_offset(4);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.imgView.mas_right).offset(8);
        make.top.bottom.equalTo(self);
        make.right.equalTo(self).offset(-15);
    }];
}

-(UIView *)imgView
{
    if (!_imgView) {
        _imgView = [UIView new];
        _imgView.backgroundColor = UIColorFromHex(kColorMain);
    
    }
    return _imgView;
}

-(UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.textColor = UIColorFromHex(kColorSubTitle);
        _titleLabel.font = UIFontSize(15);
    }
    return _titleLabel;
}
@end
